<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册-使用手机号</title>
</head>
<body>
<form action="/ft/register2/" method="post">
    {% csrf_token %}
    <table class="table">
        <tr>
            <td>用户名</td>
            <td colspan="2"><input type="text" name="name" id="name"></td>
        </tr>
        <tr>
            <td>密码</td>
            <td><input type="password" name="password" id="password"></td>
            <td></td>
        </tr>
        <tr>
            <td>手机号</td>
            <td><input type="text" name="phone" id="phone"></td>
            <td></td>
        </tr>
        <tr>
            <td>验证码</td>
            <td><input type="text" name="code" id="code"></td>
            <td><input type="button" value="获取验证码" id="get_code"></td>
        </tr>
        <tr>
            <td></td>
            <td><input type="submit" value="确定"></td>
            <td></td>
        </tr>
    </table>
</form>
<script src="/static/ft/js/jquery.min.js"></script>
<script>
   $("#get_code").click(function () {
        $.ajax({
            method:"get",
            url:"/ft/register2/phone/code/",
            data:{
                phone:$("#phone").val()
            },
            success:function (data) {
                if (data["ret"] == 1) {
                    alert("亲，发送成功，请您查看下短信！！！")
                } else if (data["ret"] == 2) {
                    alert("亲，手机号格式不正确！！！")
                } else {
                    alert("亲，出现错误了，请稍后再试试吧！！！")
                }
            },
            error:function (data) {
                alert("error")
            },
        })
   })
</script>
</body>
</html>